#include "stdafx.h"
#include "Vertex.h"


Vertex::Vertex(int id)
{
	_name = id;
}

Vertex::~Vertex()
{
	// Todo - delete the edges from yorself and from the other vertex
	// then delete the edge itself
}

void Vertex::AddEdge(Vertex *v)
{
	Edge* newEdge = new Edge(this, v);
	_edges.insert(newEdge);
}

void Vertex::PrintEdges()
{
	//std::cout << _name << ":" << std::endl;
	//Set<Edge*>::iterator it;
	//for (it = _edges.begin(); it != _edges.end(); ++it)
	//{
	//	Edge* e = *it; // Note the "*" here
	//	std::cout << e->GetDestination()->GetName() << std::endl;
	//}
	//std::cout << std::endl;
}

void Vertex::GetNeighbors(Set<Vertex*>* result)
{
	Set<Edge*>::iterator it;
	for (it = _edges.begin(); it != _edges.end(); ++it)
	{
		Edge* e = *it;
		Vertex* v = e->GetDestination();
		result->insert(v);
	}
}



